package com.xmg.mgrsite.base;

import com.xmg.p2p.base.util.JSONResult;
import com.xmg.p2p.business.query.RechargeOfflineQueryObject;
import com.xmg.p2p.business.service.IPlatformBankinfoService;
import com.xmg.p2p.business.service.IRechargeOfflineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RechargeOfflineController {
    @Autowired
    private IRechargeOfflineService rechargeOfflineService ;
    @Autowired
    private IPlatformBankinfoService platformBankinfoService ;

    /**
     * 后台充值单相关列表
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("rechargeOffline")
    public String rechargeOfflineList(@ModelAttribute("qo") RechargeOfflineQueryObject qo, Model model) {
        //获取充值单列表
        model.addAttribute("pageResult" , this.rechargeOfflineService.query(qo));
        //获取银行列表
        model.addAttribute("banks" ,this.platformBankinfoService.listAll());
        return "rechargeoffline/list";
    }


    /**
     * 后台充值单的审核
     */
    @RequestMapping("rechargeOffline_audit")
    @ResponseBody
    public JSONResult audit(Long id , String remark, int state){
        JSONResult json = new JSONResult() ;
        try {
            this.rechargeOfflineService.audit(id, remark ,state);
        } catch (Exception e) {
            e.printStackTrace() ;
            json.setSuccess(false) ;
            json.setMsg(e.getMessage()) ;
        }
        return json ;
    }

}
